/*
 * Copyright (C) 2015-2016  Nicola Spanti (RyDroid) <dev@nicola-spanti.info>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */


#include "PlanetWars2dRT-core/specific/controller/planet_update.h"
#include "PlanetWars2dRT-core/specific/controller/planet_produce.h"


EXTERN_C_BEGIN


void
planet_update_once(planet_t* a_planet, universe_t* a_universe)
{
  planet_produce(a_planet, a_universe);
  
  if(a_planet->level_changer != NULL)
    {
      a_planet->level_changer(a_planet);
    }
}

void
planet_update(planet_t* a_planet, unsigned short nb_times, universe_t* a_universe)
{
  for(unsigned short i=0; i < nb_times; ++i)
    {
      planet_update_once(a_planet, a_universe);
    }
}


EXTERN_C_END
